package com.yvon.boot.excel.param;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.util.Assert;

import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;

/**
 * 单表参数
 *
 * @author : Yvon
 * @since : 2021-07-05
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class EasyExcelParam implements Serializable {


    /**
     * excel文件名（不带拓展名)
     */
    private String excelNameWithoutExt;

    /**
     * 响应
     */
    private HttpServletResponse response;


    /**
     * 单表
     */
    private SheetParam sheet;


    public EasyExcelParam() {
    }

    /**
     * 检查不允许为空的属性
     *
     * @return this
     */
    public EasyExcelParam checkValid() {
        Assert.isTrue(ObjectUtils.allNotNull(excelNameWithoutExt, sheet, response), "导出excel参数不合法!");
        return this;
    }

}
